const connection = require("../config/mysql")

class PermissionService {
    async check(resourceName, id, userId) {
        const statement = `SELECT * FROM ${resourceName} WHERE id = ? AND user_id = ?;`
        const [result] = await connection.execute(statement, [id, userId])
        try {
            return !!result.length
        } catch (error) {
            console.log(error);
        }
    }
}

module.exports = new PermissionService()